﻿#region Using

using System.Runtime.Serialization;

using CommunicationLibrary.Converter;

using GameLogic.External;

using UnitType = CommunicationLibrary.TransportData.Enums.UnitType;

#endregion

namespace CommunicationLibrary.TransportData
{
    [DataContract(Name = "F", IsReference = true)]
    public class Unit
    {
        public Unit(IUnit unit)
        {
            this.Owner = InstanceManager.Instance.GetOrAddPlayer(unit.Owner);
            this.UnitType = UnitTypeConverter.Convert(unit.UnitType);
            this.Identifier = unit.Identifier;
        }

        [DataMember(Name = "A")]
        public int Identifier { get; private set; }

        [DataMember(Name = "B")]
        public Player Owner { get; private set; }

        [DataMember(Name = "C")]
        public UnitType UnitType { get; private set; }
    }
}